package com.cainiao.mapper;

import com.cainiao.pojo.Clazz;
import com.cainiao.pojo.ClazzQueryParam;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ClazzMapper {
    List<Clazz> page(ClazzQueryParam clazzQueryParam);

    @Delete("delete from clazz where id=#{id}")
    void delete(Integer id);

    @Insert("insert into clazz(name,room,begin_date,end_date,master_id,subject,create_time,update_time) values (#{name},#{room},#{beginDate},#{endDate},#{masterId},#{subject},#{createTime},#{updateTime})")
    void add(Clazz clazz);

    @Select("select * from clazz where id=#{id}")
    Clazz findById(Integer id);

    void update(Clazz clazz);

    @Select("select c.*, e.name as masterName from clazz c left join emp e on c.master_id = e.id")
    List<Clazz> findClazz();
}
